package cn.zhouchao.org.eum;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@AllArgsConstructor
@Getter
public enum ShopStateEnum {
    // 0,"待审核"; 1,"待激活"; 2,"驳回"; 3,"已激活"
    WAIT_AUDIT(0,"待审核"),
    WAIT_ACTIVE(1,"待激活"),
    ROLL_BACK(2,"驳回"),
    ACTIVING(3,"已激活");

    public static String getName(int code) {
        // 数组进行遍历,再过滤传进来的code【别名state】
        ShopStateEnum shopStateEnum = Arrays.stream(ShopStateEnum.values()).filter(state -> code == state.getCode())
                .findFirst().orElse(null);
        return null == shopStateEnum?"":shopStateEnum.getName();
    }

    private int code;

    private String name;
}